package TestMenu;
import MyGraph.Circle;
import static javax.swing.JOptionPane.*;
import static MyGraph.MyMenu.*;
import MyGraph.MyShape;
import MyGraph.Rectangle;
import MyGraph.Triangle;

public class ShapeMain{
	public static void main(String args[]){
		int total = Integer.parseInt(args[0]);
		System.out.println(total);
                MyShape<Double>[] graph=new MyShape[total];
                int count = 0;
		while(true){
			String []option = new String[4];
			option[0] = "[0] for create a new graph";
			option[1] = "[1] for display all graphs";
			option[2] = "[2] for calculate sum of area of all graphs";
			option[3] = "[3] for quit";
			int num = input_choice(option);
			switch(num){
				case 0: 
                                        if(count>=total)
                                            showMessageDialog(null,"Can't create more object than "+total);
                                        else{
                                        String []strA = new String[4];
					strA[0] = "[0] Add a new Circle";
					strA[1] = "[1] Add a new Rectangle";
					strA[2] = "[2] Add a new Triangle";
                                        strA[3] = "[3] Come back to MainMenu";
					int type = input_choice(strA);
					double[] nums=null;String num1,num2,num3,num4,num5,num6;
					switch(type){
                                               
						case 0:
							nums= new double[3];
							num1 = showInputDialog("Input the x");
							nums[0] = Double.parseDouble(num1);
							num2 = showInputDialog("Input the y");
							nums[1] = Double.parseDouble(num2);
							num3 = showInputDialog("Input the radius");
							nums[2] = Double.parseDouble(num3);
							graph[count++] = new Circle(nums[0],nums[1],nums[2]);							
							break;
						
						case 1:
							nums = new double[4];
							num1 = showInputDialog("Input the x");
							nums[0] = Double.parseDouble(num1);
							num2 = showInputDialog("Input the y");
							nums[1] = Double.parseDouble(num2);
							num3 = showInputDialog("Input the length");
							nums[2] = Double.parseDouble(num3);
							num4 = showInputDialog("Input the width");
							nums[3] = Double.parseDouble(num4);
							graph[count++] = new Rectangle(nums[0],nums[1],nums[2],nums[3]);
							break;						
						case 2:
							nums = new double[6];
							num1 = showInputDialog("Input the x1");
							nums[0] = Double.parseDouble(num1);
							num2 = showInputDialog("Input the y1");
							nums[1] = Double.parseDouble(num2);
							num3 = showInputDialog("Input the x2");
							nums[2] = Double.parseDouble(num3);
							num4 = showInputDialog("Input the y2");
							nums[3] = Double.parseDouble(num4);
							num5 = showInputDialog("Input the x3");
							nums[4] = Double.parseDouble(num5);
                                                        num6 = showInputDialog("Input the y3");
							nums[5] = Double.parseDouble(num6);                                                       
							graph[count++] = new Triangle(nums[0],nums[1],nums[2],nums[3],nums[4],nums[5]);
							break;
                                                case 3: //back to main menu
                                                        break;
                                                     }//end of create menu
                                        }//end of count<total
                                     break;
				case 1://display all graph objects                                
					disp_All_Object(graph);
				        break;
				case 2:
					disp_All_Object_Area(graph);
					break;				
				case 3:                                
					return;
			}//end of main menu
		}//end of while true
	}//end of main
}